package com.bw.flinkstreaming.source2.job2;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 作者QQ：43281991
 */
public class FLinkWithNotParallelSourceTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<Long> longDataStreamSource = env.addSource(new NotParallelSource()).setParallelism(1);

        SingleOutputStreamOperator<Long> result = longDataStreamSource.filter(new FilterFunction<Long>() {
            @Override
            public boolean filter(Long value) throws Exception {
                System.out.println("接收到的数据："+value);
                return value % 2 == 0;
            }
        });

        result.print().setParallelism(1);
        env.execute("FLinkWithNotParallelSourceTest");
    }
}
